package com.yulebaby.callsenter.event;

/**
 * Author: Zhangbo
 * Time: 2016/12/1
 */
public class EventFactory {

    /**
     * 刷新事件
     *
     * @return
     */
    public static RefreshEvent CreateRefreshEvent(int type) {
        if (type != RefreshEvent.refreshDataFromDatabase && type != RefreshEvent.refreshDataFromInternet && type != RefreshEvent.refreshDailyData) {
            throw new IllegalArgumentException("刷新方式异常");
        }
        return new RefreshEvent(type);
    }

    /**
     * 消息
     *
     * @return
     */
    public static MsgEvent CreateMsgEvent(Object msg) {
        if (msg instanceof String) {
            return new MsgEvent((String) msg);
        } else if (msg instanceof Integer) {
            return new MsgEvent((Integer) msg);
        }
        return null;
    }


    /**
     * 选择的Tab的事件
     *
     * @return
     */
    public static TabSelectedEvent CreateTabSelectedEvent(int postion) {
        return new TabSelectedEvent(postion);
    }

    /**
     * 选择的排序方式
     *
     * @return
     */
    public static SequenceEvent CreateSequenceTypeEvent(int type) {
        if (type != SequenceEvent.sequenceByLevel && type != SequenceEvent.sequenceByTime) {
            throw new IllegalArgumentException("排序方式异常");
        }
        return new SequenceEvent(type);
    }

    /**
     * 选择的排序方式
     *
     * @return
     */
    public static QuitEvent CreateQuitEvent() {
        return new QuitEvent();
    }

    /**
     * 显示结果
     *
     * @return
     */
    public static ShowResultEvent CreateShowResultEvent(int event) {
        if (event != ShowResultEvent.SuccessEvent && event != ShowResultEvent.FailEvent) {
            throw new IllegalArgumentException("显示结果事件类型异常");
        }
        return new ShowResultEvent(event);
    }

    /**
     * 查询静态日报
     *
     * @param time 查询的日期
     * @return
     */
    public static QueryDailyEvent CreateQueryDailyEvent(String time) {
        return new QueryDailyEvent(time);
    }
}
